function [x,y] = oral_sample(a,b,num_points,x_offset,y_offset)
%close all;
% 椭圆参数
% a x 轴方向上的半轴长度  
% b y 轴方向上的半轴长度
% num_points 生成随机点的数量
% x_offset x轴偏置量
% y_offset y轴偏置量
%num_points = 1000;

% 初始化点数组
x = zeros(num_points, 1);
y = zeros(num_points, 1);

% 计数器
count = 0;

while count < num_points
    % 生成随机点
    x_candidate = 2 * a * (rand - 0.5);
    y_candidate = 2 * b * (rand - 0.5);
    
    % 检查是否在椭圆内
    if (x_candidate / a)^2 + (y_candidate / b)^2 <= 1
        x(count + 1) = x_candidate + x_offset;
        y(count + 1) = y_candidate + y_offset;
        count = count + 1;
    end
end
%绘制椭圆内的随机点
figure;
scatter(x, y, 'filled');
axis equal;
xlabel('x');
ylabel('y');
title(['Random Points in Ellipse with a = ', num2str(a), ', b = ', num2str(b)]);
grid on;
end
